package sum.book.common.core.exception;

import lombok.Getter;
import lombok.Setter;
import sum.book.common.core.constant.ICodeEnum;


@Setter
@Getter
public class RpcException extends RuntimeException {
    /**
     * 错误编码
     */
    private ICodeEnum codeEnum;

    /**
     * 是否自定义消息
     */
    private Boolean customMessage = false;

    public RpcException(ICodeEnum codeEnum) {
        this.codeEnum = codeEnum;
    }

    public RpcException(String message, ICodeEnum codeEnum) {
        super(message);
        this.codeEnum = codeEnum;
    }

    public RpcException(String message, ICodeEnum codeEnum, Boolean customMessage) {
        this(message, codeEnum);
        this.customMessage = customMessage;
    }

    public RpcException(String message, Throwable cause, ICodeEnum codeEnum) {
        super(message, cause);
        this.codeEnum = codeEnum;
    }

    public RpcException(Throwable cause, ICodeEnum codeEnum) {
        super(cause);
        this.codeEnum = codeEnum;
    }

    public RpcException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace,
                        ICodeEnum codeEnum) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.codeEnum = codeEnum;
    }
}
